# 先执行bulid.bat，再执行release.bat

import os

# 执行命令


def exec_cmd(cmd):
    print("执行命令：" + cmd)
    os.system(cmd)


def release():
    # 1.复制文件
    ORIGINAL_PATH = './dist'
    TARGET_PATH = 'D:/python_project/mysite/-'
    PROJECT_NAME = 'mj'
    DESTINATION_PATH = TARGET_PATH+PROJECT_NAME
    # 把ORIGINAL_PATH下的文件复制到DESTINATION_PATH下,覆盖原有文件
    exec_cmd("xcopy /y /s /e /i /q " + ORIGINAL_PATH + " " + DESTINATION_PATH)
    # 2. 进入DESTINATION_PATH目录，执行git push
    # 输入提交信息
    commit_msg = input("请输入提交信息：")
    git_cmd = "cd"+ORIGINAL_PATH + "\ngit add . && git commit -m \"" + \
        commit_msg + "\" && git push -f"
    exec_cmd(git_cmd)


# main
if __name__ == "__main__":
    # 运行bulid.bat
    exec_cmd("yarn b")
    # 运行release.bat
    exec_cmd("release.bat")
